package com.lzs.kunei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzs.entity.InventoryLocatorDetail;
import com.lzs.kunei.mapper.InventoryLocatorDetailMapper;
import com.lzs.kunei.service.InventoryLocatorDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wpy
 * @since 2020-11-24
 */
@Service
public class InventoryLocatorDetailServiceImpl extends ServiceImpl<InventoryLocatorDetailMapper, InventoryLocatorDetail> implements InventoryLocatorDetailService {
    @Autowired
    private InventoryLocatorDetailMapper inventoryLocatorDetailMapper;

    @Override
    public List<InventoryLocatorDetail> selectResult(String locatorcode, String inventoryno, String result) {
        QueryWrapper<InventoryLocatorDetail> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("inventoryno",inventoryno);
        queryWrapper.eq("locatorcode",locatorcode);
        queryWrapper.eq("result",result);
       return inventoryLocatorDetailMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean selectIsExist(String locatorcode, String inventoryno, String commodity) {
        QueryWrapper<InventoryLocatorDetail> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("inventoryno",inventoryno);
        queryWrapper.eq("locatorcode",locatorcode);
        queryWrapper.eq("commoditybar",commodity);
        List<InventoryLocatorDetail> inventoryLocatorDetails = inventoryLocatorDetailMapper.selectList(queryWrapper);
        if (inventoryLocatorDetails!=null&&inventoryLocatorDetails.size()>0){
            return true;
        }else return false;
    }

    @Override
    public Integer inventoryGetQty(String locatorcode, String inventoryno, String commodity, String result) {
        QueryWrapper<InventoryLocatorDetail> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("inventoryno",inventoryno);
        queryWrapper.eq("locatorcode",locatorcode);
        queryWrapper.eq("commoditybar",commodity);
        queryWrapper.eq("result",result);
        return inventoryLocatorDetailMapper.selectList(queryWrapper).get(0).getQty();

    }
}
